package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyFileBean;
import flc.ast.bean.MyStickerBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class VideoRecordAdapter extends StkProviderMultiAdapter<MyFileBean> {

    public VideoRecordAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(70));
        addItemProvider(new VideoRecordProvider());
    }

    private class VideoRecordProvider extends BaseItemProvider<MyFileBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_video_record;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyFileBean bean) {
            Glide.with(getContext()).load(bean.getUrl()).into((ImageView) baseViewHolder.getView(R.id.ivVideoRecordItemImg));
            baseViewHolder.setText(R.id.tvVideoRecordItemName, FileUtils.getFileName(bean.getUrl()));
            baseViewHolder.setText(R.id.tvVideoRecordItemTime, TimeUtils.millis2String(FileUtils.getFileLastModified(bean.getUrl()), "yyyy-MM-dd HH:mm"));
            baseViewHolder.setText(R.id.tvVideoRecordItemSize, FileUtils.getSize(bean.getUrl()));
        }
    }
}
